package com.lansi.company.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lansi.company.bean.Company;
import com.lansi.company.mapper.CompanyMapper;

@Service
public class CompanyService implements ICompanyService{
	@Resource
	private CompanyMapper  companyMapper;
	
	public void register(Company company) {
		companyMapper.insertCompany(company);
		
	}

	public void delCompany(Integer[] ids) {
		companyMapper.deleteCompany(ids);
		
	}

	public void delCompanyById(Integer id) {
		companyMapper.deleteCompanyById(id);
		
	}

	public void updateCompany(Integer id, String name, String sn, String type, Integer gwnumber, Integer cardnumber,
			String addr, String memo) {
		Company company = new Company();
		company.setId(id);
		company.setName(name);
		company.setSn(sn);
		company.setType(type);
		company.setGwnumber(gwnumber);
		company.setCardnumber(cardnumber);
		company.setAddr(addr);
		company.setMemo(memo);
		companyMapper.updateCompany(company);
	}

	public List<Company> getCompany(String name, String sn, Integer type, Integer offset, Integer count) {
		
		return companyMapper.selectCompany(name, sn, type, offset, count);
	}

	public Company getCompanyById(Integer id) {
		
		return companyMapper.selectCompanyById(id);
	}

	public Company getCompanyByName(String name) {
		
		return companyMapper.selectCompanyByName(name);
	}

	public Company getSn(String sn) {
		
		return companyMapper.selectCompanyBySn(sn);
	}

	public Integer getCompanycount(String name, String sn, Integer type) {
		
		return companyMapper.selectCompanycount(name, sn, type);
	}

	public List<Company> selectCompanySnName() {
		
		return companyMapper.selectCompanySnName();
	}

}
